<?php


namespace App\Models\Game;


use App\Models\MainDB\Gift;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;

class ProductSku extends Model
{
    protected $connection = 'mysql_game';

    protected $table = 'product_sku';

    public $timestamps = false;

    public function gift()
    {
        $model = new Gift();
        $model->setConnection('mysql');
        $query = $model->newQuery();
        return new HasOne($query, $this, 'id', 'product_id');
    }

//$data['type'] = $data['type'] == 0 ? 'gift' : 'balance';

    public function getTypeAttribute($key)
    {
        $arr = ['gift' => 0, 'balance' => 1];
        return $arr[$key];
    }
}